/**
 * @author Eric Jahn
 * Course: Object Oriented Programming
 * Final Project
 * Due Date: August 3, 2012
 */
package oop.chat.user;
import java.io.Serializable;
import java.security.InvalidParameterException;

/**
 * manage contact information about a user
 * @author Eric Jahn
 */
public class Contact implements Serializable
{
    //general information about the user 	
    private String PID;
    private String firstName;
    private String lastName;
    private String year;
    private String program;

    /**
     * initialize contact information with pid and the full name
     * @param	pid	String
     * @param	firstName	String
     * @param	lastName	String
     */
    public Contact(String pid, String firstName, String lastName)
    {
        this(pid, firstName, lastName, "", "");
    }

    /**
     * initialize contact information with pid, full name, year and the program
     * @param	pid	String
     * @param	firstName	String
     * @param	lastName	String
     * @param	year	String
     * @param	program	String
     */
    public Contact(String pid, String firstName, String lastName, String year, String program)
    {
        this.PID = pid;
        this.firstName = firstName;
        this.lastName = lastName;
        this.year = year;
        this.program = program;
    }

    /**
     * initialize contact information with array of parameters
     * @param	parameter  String[]
     */
   public Contact(String[] parameter)
    {
        // fallthrough based on number of elements in array
        switch (parameter.length)
        {
            case 5:
                this.program = parameter[4];
                this.year = parameter[3];
            case 3:  
                this.lastName = parameter[2];
                this.firstName = parameter[1];
                this.PID = parameter[0];
                break;
            default:
                throw new InvalidParameterException("Incorrect number of parameters");
        }
    }
    /**
     * gets the pid of a user
     * @return	PID	String
     */
    public final String getPID()
    {
        return PID;
    }

    /**
     * sets the PID of a user
     * @param	PID	String
     */
    public void setPID(String PID)
    {
        this.PID = PID;
    }

    /**
     * gets the full name of the person as one string
     * @return	firstName + lastName	String
     */
    public final String getFullName()
    {
        return this.firstName + " " + this.lastName;
    }

    /**
     * gets the first name of a user
     * @return	firstName	String
     */
    public final String getFirstName()
    {
        return this.firstName;
    }

    /**
     * sets the first name of a user
     * @param	firstName	String
     */
    public void setFirstName(String firstName)
    {
        this.firstName = firstName;
    }

    /**
     * gets the last name of a user
     * @return	lastName	String
     */
    public final String getLastName()
    {
        return this.lastName;
    }

    /**
     * sets the last name of a user
     * @param	lastName	String
     */
    public void setLastName(String lastName)
    {
        this.lastName = lastName;
    }

    /**
     * gets the program of a user
     * @return	program	String
     */
    public final String getProgram()
    {
        return this.program;
    }

    /**
     * sets the program of a user
     * @param	program	String
     */
    public void setProgram(String program)
    {
        this.program = program;
    }

    /**
     * gets the year of a user
     * @return	year	String
     */
    public final String getYear()
    {
        return this.year;
    }

    /**
     * sets the year of a user
     * @param	year	String
     */
    public void setYear(String year)
    {
        this.year = year;
    }
    
    @Override
    public String toString()
    {
        StringBuffer buffer = new StringBuffer();
        
        buffer.append(PID);
        buffer.append(", ");
        buffer.append(firstName);
         buffer.append(", ");
        buffer.append(lastName);
         buffer.append(", ");
        buffer.append(year);
         buffer.append(", ");
        buffer.append(program);
        
        return buffer.toString();
    }
}